import 'package:flutter/material.dart';
//下方导航栏
List<Widget> tabViewList = [
  HomePage(),
  Placeholder(),
  Placeholder(),
  Placeholder(),
];
List <BottomNavigationBarItem> barItemList = [
  BottomNavigationBarItem(icon: Icon(Icons.home), label: '首页'),
  BottomNavigationBarItem(icon: Icon(Icons.add), label: '发布'),
  BottomNavigationBarItem(icon: Icon(Icons.message), label: '消息'),
  BottomNavigationBarItem(icon: Icon(Icons.person), label: '我的'),
];
class HomePage extends StatefulWidget {
  const HomePage({super.key});

  @override
  State<HomePage> createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> {
  int _selectedIndex = 0;

  void _onItemTapped(int index) {
    setState(() {
      _selectedIndex = index;
    });
  }
  @override
  Widget build(BuildContext context) {
    return Scaffold(
body: tabViewList[_selectedIndex],
      bottomNavigationBar: BottomNavigationBar(
        type: BottomNavigationBarType.fixed,
        items:  barItemList,
        currentIndex: _selectedIndex,
        selectedItemColor: Colors.blue,
        onTap: _onItemTapped,
      )
    );
  }
}